﻿using Endos.Wodo.Business;
using Microsoft.AspNet.SignalR;
using Microsoft.AspNet.SignalR.Hubs;
using Ninject.Activation;
using Ninject.Modules;
using System;

namespace Endos.Wodo.Web.Hubs
{
    public sealed class Module : NinjectModule
    {
        private static Func<IContext, NotifierContext<TNotifier>> BindNotifierContext<THub, TNotifier>()
            where THub : IHub
            where TNotifier : Notifier, new()
        {
            return c => new NotifierContext<TNotifier>(GlobalHost.ConnectionManager.GetHubContext<THub>().Clients);
        }

        public override void Load()
        {
            Bind<INotifierContext<ICharacterNotifier>>().ToMethod(BindNotifierContext<CharacterHub, CharacterNotifier>());
        }
    }
}